package com.xxl.vueadmin.common;

import lombok.Data;

import javax.jws.Oneway;

/**
 * @version 1.0
 * @Author: 许啸林
 * @Date: 2021/7/28 14:59
 */
@Data
public class Result {
    private final static int SUCCESS_CODE = 200;
    private final static String SUCCESS_MSG = "操作成功";
    private final static int ERROR_CODE = 400;
    private final static String ERROR_MSG = "操作失败";
    private int code;
    private Object data;
    private String msg;

    public static Result success(Object data) {
        return success(SUCCESS_CODE, SUCCESS_MSG, data);
    }
    public static Result fail() {
        return fail(ERROR_CODE, ERROR_MSG, null);
    }
    public static Result fail(String msg) {
        return fail(ERROR_CODE, msg, null);
    }

    public static Result success(int code, String msg, Object data) {
        Result r = new Result();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }
    public static Result fail(int code, String msg, Object data) {
        Result r = new Result();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }
}
